package gov.nasa.anml.lifted;

import gov.nasa.anml.PDDL;
import gov.nasa.anml.State;

import gov.nasa.anml.PDDL.Time;
import gov.nasa.anml.utility.SimpleBoolean;
import gov.nasa.anml.utility.SimpleObject;
import gov.nasa.anml.utility.SimpleVoid;

public class ANMLBoolean extends SimpleBoolean implements ConstantExpression<SimpleBoolean> {

	// need new True/False values because the ones in SimpleBoolean don't
	// have the typeCode(), value(State), and ANMLBoolean value() methods
	public static final ANMLBoolean True = new ANMLBoolean(true),
									False =  new ANMLBoolean(false);
	
	// cannot override public static final
	// because of the silly invocation like:
	// SimpleBoolean foo = new ANMLBoolean(blah);
	// foo.make(...);
	// which invokes the following method:
	public static ANMLBoolean make(boolean v) {
		return v ? True : False;
	}
	private ANMLBoolean(boolean v) {
		this.v = v;
	}
	
	public ANMLBoolean value() {
		return this;
	}

	public ANMLBoolean value(State s) {
		return this;
	}

	public TypeCode typeCode() {
		return TypeCode.Boolean;
	}

	public History<SimpleVoid> storage(State p, State c) {
		return null;
	}

	public boolean apply(State p, int contextID, State c) {
		return this == True;
	}

	public void translateDecl(PDDL pddl, Interval unit) {
	}	
	
	public void translateStmt(PDDL pddl, Interval unit, Time part) {
		if (!v) {
			unit.getPDDLConditions().add(pddl.FalseCondition);
		}
	}
	
	public PDDL.Expression translateExpr(PDDL pddl, Interval unit) {
		return v ? pddl.TrueRef : pddl.FalseRef;
	}
	
	public PDDL.Expression translateLValue(PDDL pddl, Interval unit) {
		return null;
	}

	public PDDL.Argument translateArgument(PDDL pddl, Interval unit) {
		// TODO: 
		// could return true and false objects for parameters to actions.
		return null;
	}
	

}
